/*验证密码代码*/
function word() {
    let phones=/^[1][3,4,5,7,8][0-9]{9}$/;
    if (!phones.test(i.value)){
        v.info="手机号码格式不正确,请重填!"
        i.value="";
    }
}
function pass(){
    let passwords=/^\w{6,12}$/;
    if (!passwords.test(p2.value)){
        v.info="密码格式不正确,请重填!"
        p1.value = "";
        p2.value = "";
    }
    if (p1.value != p2.value) {
        v.info = "两次输入的密码不相同!请重新输入"
        p1.value = "";
        p2.value = "";
    }
}
let v = new Vue({
    el: ".lgd_form",
    data: {
        info: ""
    },
    methods: {
        reg: function () {
            let data = new FormData(document.querySelector("form"));
            axios.post("/selectByPhone", data).then(function (response) {
                /*判断手机号码是否为空*/
                if (i.value == "") {
                    v.info = "手机号码不能为空";
                    return;
                }
                /*验证密码是否为空*/
                if (p1.value == "" || p2.value == "") {
                    v.info = "密码不能为空";
                    return;
                }
                /*注册结果*/
                if (response.data == 1) {
                    alert("注册成功");
                    location.href="/login.html"
                }
                if (response.data == 2) {
                    alert("用户名已经存在!")
                    location.reload();
                }
            })
        },

    }
})